package com.cloudsigns.factorymanager2.engineering.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.BaseActivity;
import com.cloudsigns.factorymanager2.R;

public class EngineeringPublicationOrderHasBeenReceivedActicity extends BaseActivity{
    private RelativeLayout rl_back;
    private TextView tv_title;
    private ImageView img_project_select,img_infor_select;
    private LinearLayout ll_engineering_info_content;
    private TextView tv_receive_people_colon,tv_reception_time_colon;
    private TextView edt_detail_address,edt_completion_date,edt_dispath_order_person,edt_dispath_order_time,edt_receive_people,edt_reception_time;
    private ListView lv;
    private String type;

    @Override
    protected void onBaseCreate(Bundle savedInstanceState) {
        setContentView(R.layout.layout_engineering_publication_order_hasbeen_received);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_back = findViewById(R.id.rl_back);
        tv_title = findViewById(R.id.tv_title);
        edt_detail_address=findViewById(R.id.edt_detail_address);
        edt_completion_date=findViewById(R.id.edt_completion_date);
        edt_dispath_order_person=findViewById(R.id.edt_dispath_order_person);
        edt_dispath_order_time=findViewById(R.id.edt_dispath_order_time);
        edt_receive_people=findViewById(R.id.edt_receive_people);
        edt_reception_time=findViewById(R.id.edt_reception_time);
        tv_receive_people_colon=findViewById(R.id.tv_receive_people_colon);
        tv_reception_time_colon=findViewById(R.id.tv_reception_time_colon);
        ll_engineering_info_content=findViewById(R.id.ll_engineering_info_content);
        img_project_select=findViewById(R.id.img_project_select);
        img_infor_select=findViewById(R.id.img_infor_select);
        lv=findViewById(R.id.lv);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        tv_title.setText(getResources().getString(R.string.publication));
        img_project_select.setBackgroundResource(R.mipmap.arrow_down_icon);
        img_infor_select.setBackgroundResource(R.mipmap.arrow_down_icon);

        Intent intent=getIntent();
        type=intent.getStringExtra("type");
        if ("BackEngineeringOrderFragment".equals(type)){
            tv_receive_people_colon.setText("退  回  人：");
            tv_reception_time_colon.setText("退回时间：");
        }
    }

    // 项目名称 收放
    private void showEngineeringInfoDialog() {
        if (ll_engineering_info_content.getVisibility() == View.VISIBLE) {
            ll_engineering_info_content.setVisibility(View.GONE);
            img_project_select.setBackgroundResource(R.mipmap.arrow_down_icon);
        } else {
            ll_engineering_info_content.setVisibility(View.VISIBLE);
            img_project_select.setBackgroundResource(R.mipmap.arrow_top);
        }
    }

    // 上刊信息 收放
    private void showEngineeringInfoSelect() {
        if (lv.getVisibility() == View.VISIBLE) {
            lv.setVisibility(View.GONE);
            img_infor_select.setBackgroundResource(R.mipmap.arrow_down_icon);
        } else {
            lv.setVisibility(View.VISIBLE);
            img_infor_select.setBackgroundResource(R.mipmap.arrow_top);
        }
    }


    @Override
    public void setListener() {
        rl_back.setOnClickListener(this);
        img_project_select.setOnClickListener(this);
        img_infor_select.setOnClickListener(this);
    }

    @Override
    public void widgetClick(View v) {
        switch (v.getId()){
            case R.id.rl_back:
                finish();
                break;
            // 项目名称 收缩
            case R.id.img_project_select:
                showEngineeringInfoDialog();
                break;
                // 上刊信息 收缩
            case R.id.img_infor_select:
                showEngineeringInfoSelect();
                break;
        }
    }
}
